var mysql = require('mysql');

var mysqlPool = null;

export function createMysqlPool (configObj) {
    if(mysqlPool == null || selectHost != configObj.host) {
        selectHost = configObj.host;
        mysqlPool = mysql.createPool({
            host: configObj.host,
            user: configObj.user,
            password: configObj.password,
            port: configObj.port,
            database: 'mysql',
            // 最大连接数，默认为10
            connectionLimit: 10,
        })
    }
}

export function getMysqlPool () {
    return mysqlPool;
}